using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Door : MonoBehaviour
{
    [SerializeField] public bool isOpen = false;
    [SerializeField] LayerMask layerMask;
    public BoxCollider2D centerCollider;
    public BoxCollider2D leftCollider;
    public BoxCollider2D rightCollider;

    Animator animator;

    private void Awake()
    {
        animator = GetComponent<Animator>();
    }
    private void Start()
    {
        Interacte(null);
        ChangeAfterInteracte();
    }
    public void ChangeBeforeInteracte()
    {
        centerCollider.enabled = true;
        leftCollider.enabled = false;
        rightCollider.enabled = false;
    }

    public void Interacte(GameObject trigger)
    {
        isOpen = !isOpen;
        animator.SetBool("isOpen", isOpen);
    }
    public void CloseDoor()
    {
        isOpen = false;
        animator.SetBool("isOpen", isOpen);
    }
    public void ChangeAfterInteracte()
    {
        centerCollider.enabled = false;
        leftCollider.enabled = true;
        rightCollider.enabled = true;
    }
}
